﻿#ifndef MYOPENGLWIDGET_H
#define MYOPENGLWIDGET_H

#include <QKeyEvent>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLWidget>

#include <QTime>
#include <QTimer>
#include <QVector3D>
#include <QVector>
#include <math.h>
/*
    画三维图形，主要通过
        uniform mat4 model;
        uniform mat4 view;
        uniform mat4 projection;
*/

class MyOpenGLWidget : public QOpenGLWidget, QOpenGLFunctions_3_3_Core {
    Q_OBJECT
  public:
    enum Shape { None, Rect, Circle, Triangle };

    MyOpenGLWidget( QWidget *parent = nullptr );
    ~MyOpenGLWidget();

    void drawShape( Shape shape );
    void setWireframe( bool wireframe );

  protected:
    virtual void initializeGL();
    virtual void resizeGL( int w, int h );
    virtual void paintGL();
    virtual void keyPressEvent( QKeyEvent *event ) override;

  signals:

  public slots:
    void on_timerout();

  private:
    Shape                m_shape;
    QOpenGLShaderProgram m_shaderProgram;
    QOpenGLTexture *     m_textureWall;  // 1 步骤一
    QOpenGLTexture *     m_textureFreep; // 1 步骤一
    QOpenGLTexture *     m_textureSamll; // 1 步骤一

    QTimer m_timer;
};

#endif // MYOPENGLWIDGET_H
